plugins {
    id 'anime.mod-bundler'
    id 'org.hidetake.ssh'
}

dependencies {
    compileOnly 'dev.xdark:clientapi:2.0.4'

    implementation 'ru.cristalix:client-sdk:isClientMod-SNAPSHOT'
    implementation 'ru.cristalix:ui-engine-v2:1.2.19'
    implementation 'implario:humanize:1.1.3'
    implementation project(':protocol')
}

mod {
    name = "Animation Api"
    main = "Main"
    author = "func"
    jarFileName = "animation-api-production.jar"
    setVersion(project.version)
}

def modJar = layout.buildDirectory.file("libs/animation-api-production.jar")

task upload() {
    dependsOn(tasks.jar)
    if (!System.getenv("SSH_PASSPHRASE")) return
    remotes {
        webServer {
            host = 'storage.c7x.ru'
            user = 'func'
            knownHosts = allowAnyHosts
            identity = file(System.getenv("RSA_PATH") ?: "C://Users/func/.ssh/id_rsa")
            passphrase = System.getenv("SSH_PASSPHRASE")
        }
    }
    doLast {
        ssh.run {
            session(remotes.webServer) {
                def dir = "/var/www/html/func/animation-api/v" + project.version + "/"
                execute 'mkdir -p ' + dir
                put from: modJar.get().asFile,
                into: dir
            }
        }
    }
}
